// components/cart/cart.js
const computedBehavior = require("miniprogram-computed").behavior;
Component({
  behaviors: [computedBehavior],
  properties: {},
  data: {
    list: [],
  },
  methods: {},
  lifetimes: {},
  pageLifetimes: {
    show() {
      let cart = wx.getStorageSync("cart") || [];
      this.setData({
        list: cart,
      });
    },
  },
  computed: {
    totalPrice(data) {
      let result = data.list.reduce((total, item) => {
        return (total += item.count * item.price);
      }, 0);
      return result;
    },
  },
});
